package com.sky.mapper.admin;

import com.sky.dto.GoodsSalesDTO;
import com.sky.vo.OrderDayAmountVO;
import io.lettuce.core.dynamic.annotation.Key;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReportMapper {
    /**
     * 根据日期查询营业额
     * @param
     * @return
     */
    @Select("select sum(amount) from orders where order_time like concat(#{day},'%')")
    Double selectSalesVolumesByDay(String day);

    /**
     * 订单统计
     * @param begin
     * @param
     * @return
     */
    List<OrderDayAmountVO> orderReport(LocalDate begin, LocalDate end);

    /**
     * 销量统计
     * @param begin
     * @param
     * @return
     */
    List<GoodsSalesDTO> dishTop10(LocalDate begin, LocalDate end);

    /**
     * 营业额统计
     * @param begin
     * @param end
     * @return
     */
    List<OrderDayAmountVO> turnoverStatistics(LocalDate begin, LocalDate end);


    /**
     * 获取新增用户数量
     * @param
     * @param
     * @return
     */

    //@MapKey("")
    Map<String, Object> getNewUserCount(@Param("begin") String oldBegin,
                                        @Param("end") String oldEnd,
                                        @Param("list") List<String> dateList);


    /**
     * 获取总用户数量
     * @param oldBegin
     * @return
     */
    Integer getAllUserByDate(String oldBegin);

    /**
     *获取概览数据
     * @param begin
     * @param now
     * @return
     */
    OrderDayAmountVO exportData(LocalDate begin, LocalDate now);

    /**
     * 获取新增用户数量
     * @param begin
     * @return
     */
    @Select("select count(id) from user where create_time>#{begin} and create_time<#{end}")
    Integer getNewUsers(LocalDate begin,LocalDate end);
}
